package io.github.kouleen.manager.listener.server;

import io.github.kouleen.manager.ManagerX;
import io.github.kouleen.minecraft.core.lang.annotation.MinecraftPluginAutoInject;
import io.github.kouleen.minecraft.core.lang.annotation.MinecraftPluginListener;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;

/**
 * 用于处理插件被禁用时的相关操作
 * @author zhangqing
 * @since 2025/2/26 11:05
 */
@MinecraftPluginListener
public class PluginDisableListener implements Listener {

    @MinecraftPluginAutoInject
    private ManagerX managerX;

    @EventHandler
    public void onPluginDisableListener(PluginDisableEvent pluginDisableEvent){
        Plugin plugin = pluginDisableEvent.getPlugin();
        PluginDescriptionFile pluginDescription = plugin.getDescription();
        managerX.removePlugin(plugin.getName() + pluginDescription.getVersion());
    }
}